/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2022-03-13     DRZZZ       the first version
 */
#ifndef APPLICATIONS_RELAY_MANAGEMENT_H_
#define APPLICATIONS_RELAY_MANAGEMENT_H_
//八路继电器驱动
#include "head.h"
#if (CODE == FIRST)
#define RELAY_PIN_1        GET_PIN(A,  6)
#define RELAY_PIN_2        GET_PIN(A, 11)
#define RELAY_PIN_3        GET_PIN(G,  7)
#define RELAY_PIN_4        GET_PIN(C,  9)
#define RELAY_PIN_5        GET_PIN(A,  8)
#define RELAY_PIN_6        GET_PIN(D,  2)
#define RELAY_PIN_7        GET_PIN(C, 10)
#define RELAY_PIN_8        GET_PIN(D,  7)
#endif

#if (CODE == SECOND)
// 八路继电器
#define RELAY_PIN_1        GET_PIN(B,  9)
#define RELAY_PIN_2        GET_PIN(B,  7)
#define RELAY_PIN_3        GET_PIN(B,  5)
#define RELAY_PIN_4        GET_PIN(B,  3)
#define RELAY_PIN_5        GET_PIN(G, 14)
#define RELAY_PIN_6        GET_PIN(D,  2)
#define RELAY_PIN_7        GET_PIN(C, 10)
#define RELAY_PIN_8        GET_PIN(D,  7)
// 电机驱动
#define MOTO_AIN_1         GET_PIN(E,  6)
#define MOTO_AIN_2         GET_PIN(E,  4)
#define MOTO_AIN_PWM       GET_PIN(B,  1)
#define MOTO_BIN_1         GET_PIN(E,  2)
#define MOTO_BIN_2         GET_PIN(E,  0)
#define MOTO_BIN_PWM       GET_PIN(G, 12)
#define RIGHTMOTO          MOTO_AIN_PWM
#define RIGHTMOTO_IN1      MOTO_AIN_1
#define RIGHTMOTO_IN2      MOTO_AIN_2
#define LEFTMOTO           MOTO_BIN_PWM
#define LEFTMOTO_IN1       MOTO_BIN_1
#define LEFTMOTO_IN2       MOTO_BIN_2
// 推杆三个状态
#define WAIT               2
#define PUSH               3
#define PULL               4
#endif
// 限位开关驱动
#define KEY_PIN_1          GET_PIN(A, 13)
#define KEY_PIN_2          GET_PIN(B,  4)

#define STOP               0x00
#define WORK               0x01


extern u_int8_t relay_1_flag,relay_2_flag,
                relay_3_flag,relay_4_flag,
                relay_5_flag,relay_6_flag,
                relay_7_flag,relay_8_flag;

void Set_Motor(uint8_t R_motor,uint8_t L_motor);
void Set_Peripheral(uint8_t Peripheral_name, uint8_t relay_state);

#endif /* APPLICATIONS_RELAY_MANAGEMENT_H_ */
